﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Configuration;
using System.IO;
using System.Web.Configuration;

namespace MVCSingTowerMall
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Retail & Dining", // Route name
                "Store/{action}/{subcategoryName}", // URL with parameters
                new { controller = "Store", action = "index", subcategoryName = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "BookEventHall", // Route name
                "BookEventHall/", // URL with parameters
                new { controller = "EventHallBook", action = "Booking" } // Parameter defaults
            );

            routes.MapRoute(
                "SingTowerPromotions", // Route name
                "Promotion/{action}", // URL with parameters
                new { controller = "Promotions", action = UrlParameter.Optional } // Parameter defaults
            );

            

            routes.MapRoute(
                "ViewAll", // Route name
                "Store/ViewAll/{categoryName}", // URL with parameters
                new { controller = "Store", action = "ViewAll", categoryName = UrlParameter.Optional } // Parameter defaults
            );

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterRoutes(RouteTable.Routes);

            /* Added for easy debug need to be removed on deployment */
            string root = Server.MapPath("~");
            string parent = Path.GetDirectoryName(Path.GetDirectoryName(root));
            AppDomain.CurrentDomain.SetData("DataDirectory",parent+"\\Database");

        }
    }
}